<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5shiv.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->
    <link rel="stylesheet" type="text/css" href="../static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="../lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="../static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/style.css" />


    <!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
    <title>添加子商户</title>
</head>

<body>
    <article class="page-container">
        <form class="form form-horizontal" id="form-admin-add">
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">
                    <span class="c-red">*</span>账号：</label>
                <div class="formControls col-xs-5 col-sm-6">
                    <input type="text" class="input-text" value="" placeholder="账号" id="adminName" name="adminName" required="required">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">
                    <span class="c-red">*</span>登录密码：</label>
                <div class="formControls col-xs-5 col-sm-6">
                    <input type="password" class="input-text" autocomplete="off" value="" placeholder="登录密码" id="password" required="required">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">
                    <span class="c-red">*</span>公司名称：</label>
                <div class="formControls col-xs-5 col-sm-6">
                    <input type="text" class="input-text" placeholder="" name="" id="Corporatename" required="required">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">
                    <span class="c-red">*</span>身份证名称：</label>
                <div class="formControls col-xs-5 col-sm-6">
                    <input type="text" class="input-text" autocomplete="off" placeholder="身份证名称" id="idname" required="required">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">
                    <span class="c-red">*</span>身份证号：</label>
                <div class="formControls col-xs-5 col-sm-6">
                    <input type="text" class="input-text" autocomplete="off" placeholder="身份证号" id="idnumber" required="required">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">
                    <span class="c-red">*</span>手机：</label>
                <div class="formControls col-xs-5 col-sm-6">
                    <input type="text" class="input-text" value="" placeholder="" id="phone" name="phone" required="required">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">
                    <span class="c-red">*</span>邮箱：</label>
                <div class="formControls col-xs-5 col-sm-6">
                    <input type="text" class="input-text" placeholder="@" name="email" id="email" required="required">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">开户行地址：</label>
                <div class="formControls col-xs-5 col-sm-6" id="provinces-city">

                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">
                    <span class="c-red">*</span>ICP备案登记号：</label>
                <div class="formControls col-xs-5 col-sm-6">
                    <input type="text" class="input-text" placeholder="" name="" id="adminRole" required="required">
                </div>
            </div>
            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <input class="btn btn-primary radius" type="button" id="updatames" value="&nbsp;&nbsp;保存&nbsp;&nbsp;">
                </div>
            </div>
        </form>
    </article>

    <!--_footer 作为公共模版分离出去-->
    <script type="text/javascript" src="../lib/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="../lib/layer/2.4/layer.js"></script>
    <script type="text/javascript" src="../static/h-ui/js/H-ui.min.js"></script>
    <script type="text/javascript" src="../static/h-ui.admin/js/H-ui.admin.js"></script>
    <!--/_footer 作为公共模版分离出去-->

    <!--请在下方写此页面业务相关的脚本-->
    <script type="text/javascript" src="../lib/jquery.validation/1.14.0/jquery.validate.js"></script>
    <script type="text/javascript" src="../lib/jquery.validation/1.14.0/validate-methods.js"></script>
    <script type="text/javascript" src="../lib/jquery.validation/1.14.0/messages_zh.js"></script>
    <script type="text/javascript" src="../js/config.js"></script>
    <!-- 三级联动 -->
    <script src="../lib/provincesCity/jquery.provincesCity.js"></script>
    <script src="../lib//provincesCity/provincesData.js"></script>
    <script type="text/javascript">
        $(function () {
            // 初始化三级联动
            $("#provinces-city").ProvinceCity();

            $("#updatames").click(function () {
                $('#updatames').attr('disabled','true');

                var sub_obj = {
                    account: {
                        reg: 'required',
                        val: $('#adminName').val(),
                        msg: '用户名不能为空'
                    },
                    pwd: {
                        reg: 'required',
                        val: $('#password').val(),
                        msg: '密码不能为空'
                    },
                    userMerchantName: {
                        reg: 'required',
                        val: $('#Corporatename').val(),
                        msg: '公司名不能为空'
                    },
                    id: {
                        reg: 'required',
                        val: $('#idnumber').val(),
                        msg: '身份证号不能为空'
                    },
                    userName: {
                        reg: 'required',
                        val: $('#idname').val(),
                        msg: '省份证不能为空'
                    },
                    phone: {
                        reg: 'required',
                        val: $('#phone').val(),
                        msg: '手机号不能为空'
                    },
                    mailbox: {
                        reg: 'required',
                        val: $('#email').val(),
                        msg: '邮箱不能为空'
                    },
                    ipcNo: {
                        reg: 'required',
                        val: $('#adminRole').val(),
                        msg: '备案号不能为空'
                    },
                    country: {
                        reg: 'required',
                        val: $('#country').val(),
                        msg: '请选择地址'
                    },
                    province: {
                        reg: 'required',
                        val: $('#province').val(),
                        msg: '请选择地址'
                    },
                    city: {
                        reg: 'required',
                        val: $('#city').val(),
                        msg: '请选择地址'
                    },
                    pUserMerchantNo:{
                        reg:'required',
                        val:$.cookie('user_mcno'),
                        msg:'登录超时'
                    }
                }


                function check(cheked_obj, success, error) {
                    var con = 1;
                    $.each(cheked_obj, function (key, val) {
                        if (con == 1) {
                            if (val['reg'] == 'required') {
                                if (!val['val']) {
                                    error(val);
                                    con = 0;
                                }
                            }
                        }
                    });
                    if (con == 1) {
                        var data = {};
                        $.each(cheked_obj, function (key, val) {
                            data[key] = val['val'];
                        });
                        success(data);
                    }
                }


                // 检测
                check(sub_obj, function (data) {
                    $.ajax({
                        type: 'post',
                        url: $.webConfig.basicUrl + "/chuyangPay/user/addsupUserDB",
                        data: data,
                        dataType: "json",
                        success: function (data) {
                            if (data['code'] == 200) {
                                layer.msg('添加成功!', {
                                    icon: 1,
                                    time: 1000
                                });
                            }
                            $('#updatames').removeAttr('disabled');
                            setTimeout(function(){
                                window.location.replace(location.href);                            
                            },600);
                        },
                        error: function (XmlHttpRequest, textStatus, errorThrown) {
                            layer.msg('error!', {
                                icon: 2,
                                time: 1000
                            });
                            $('#updatames').removeAttr('disabled');
                        }
                    });
                    
                }, function (err) {
                    layer.alert(err['msg']);
                    $('#updatames').removeAttr('disabled');
                });
            });
        });
    </script>
    <!--/请在上方写此页面业务相关的脚本-->
</body>

</html>